using ValidationFramework;
using ValidationFramework.Reflection;

namespace ExampleLibraryCSharp.NewRule
{
    public class RequiredCharacterRuleAttribute : RuleAttribute
    {
        #region Fields

        //the required character
        private readonly char requiredCharacter;

        #endregion


        #region Constructors

        /// <param name="requiredCharacter">The required character.</param>
        public RequiredCharacterRuleAttribute(char requiredCharacter)
        {
            this.requiredCharacter = requiredCharacter;
        }

        #endregion


        #region Properties

        /// <summary>
        /// Gets the required character.
        /// </summary>
        public char RequiredCharacter
        {
            get
            {
                return requiredCharacter;
            }
        }

        #endregion


        #region Methods

    	/// <summary>
    	/// Create a <see cref="Rule"/> based on the provided <see cref="InfoDescriptor"/>.
    	/// </summary>
    	/// <param name="infoDescriptor">The <see cref="InfoDescriptor"/> to create a <see cref="Rule"/> for.</param>
    	/// <returns>The <see cref="Rule"/>  created.</returns>
    	public override Rule CreateInstance(InfoDescriptor infoDescriptor)
        {
            return new RequiredCharacterRule(ErrorMessage, 
                UseErrorMessageProvider, requiredCharacter);
        }

        #endregion
    }
}